package CollectionTask;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class NewForDemo {
    public static void main(String[] args) {
       /* String[]array={"one","two","three","four","five"};
        for (int i=0;i<array.length;i++){
            System.out.println(array[i]);
        }
        for (String str:array){
            System.out.println(str);
        }
        System.out.println("-------------------");


        Collection<String>a=new ArrayList<>();
        a.add("one");
        a.add("two");
        a.add("three");
        a.add("four");
        a.add("five");
        Iterator<String> it=a.iterator();
        while(it.hasNext()){
            String str=it.next();
            System.out.println(str);
        }
        for (String str:a){
            System.out.println(str);
        }*/


        String[]array={"1","2","3","4","5"};
        for (int i=0;i<array.length;i++){
            System.out.println(array[i]);
        }
        for (String str:array){
            System.out.println(str);
        }
        System.out.println("-------------------");


        Collection<String>c=new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator<String>it=c.iterator();
        while (it.hasNext()){
            String str=it.next();
            System.out.println(str);
        }
    }
}
